package com.evolutioninc.wordfinder;

import java.io.IOException;
import java.io.InputStreamReader;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class WordFinder extends TabActivity {

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		loadWordLists("dict.txt");
		
		TabHost tabHost = getTabHost();
		 
        // Tab for Solver
        TabSpec solverSpec = tabHost.newTabSpec("Solver");
        // setting Title and Icon for the Tab
        solverSpec.setIndicator("Solver");
        Intent photosIntent = new Intent(this, SolverActivity.class);
        solverSpec.setContent(photosIntent);
 
        // Tab for Builder
        TabSpec builderSpec = tabHost.newTabSpec("Builder");
        builderSpec.setIndicator("Builder");
        Intent songsIntent = new Intent(this, BuilderActivity.class);
        builderSpec.setContent(songsIntent);
 
        // Adding all TabSpec to TabHost
        tabHost.addTab(solverSpec); // Adding Solver tab
        tabHost.addTab(builderSpec); // Adding Builder/Unscramble tab

	}
	
	/**
	 * Load dictionary file into memory
	 * @param fileName
	 */
	private void loadWordLists(String fileName){

		try {
			StringUtil.createDictionary(new InputStreamReader(getAssets().open(fileName)));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}